﻿<?xml version="1.0" encoding="utf-8" ?>
<Rules FriendlyName="SharePoint Best Practices Rules">

  <Rule TypeName="DisposeSPSiteAndSPWebObjectsCreated"
        Category="SharePoint.BestPractices"
        CheckId="SP0001">
    <Name>Dispose created SPSite or SPWeb objects</Name>
    <Description>When you create a SPSite or a SPWeb object with a new operator, the creating application must dispose of it.</Description>
    <Resolution Name="Base">In method {0}, Dispose was not called on {1}.</Resolution>
    <Resolution Name="Constructor">In method {0}, constructor called for {1}. This type should be assigned and explicitely disposed.</Resolution>
    <Resolution Name="RootWebProp">In method {0}, Dispose was not called on {1} after a LockIssue, SecondaryContact, or Owner property call.</Resolution>
    <Resolution Name="PublishingWeb">In method {0}, Close was not called on {1}, which is enumerated from the PublishingWebCollection returned by GetPublishingWebs.</Resolution>
    <MessageLevel Certainty="100">Warning</MessageLevel>
    <FixCategories>NonBreaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="DisposeSPWebReturnedFromMethod"
        Category="SharePoint.BestPractices"
        CheckId="SP0002">
    <Name>Dispose SPWeb returned from a method</Name>
    <Description>SharePoint methods that return other SPWeb objects (such as SPSite.OpenWeb) create new items and should be disposed of.</Description>
    <Resolution Name="Base">In method {0}, Dispose was not called on {1}.</Resolution>
    <Resolution Name="Constructor">In method {0}, constructor called for {1}. This type should be assigned and explicitely disposed.</Resolution>
    <Resolution Name="RootWebProp">In method {0}, Dispose was not called on {1} after a LockIssue, SecondaryContact, or Owner property call.</Resolution>
    <Resolution Name="PublishingWeb">In method {0}, Close was not called on {1}, which is enumerated from the PublishingWebCollection returned by GetPublishingWebs.</Resolution>
    <MessageLevel Certainty="75">Warning</MessageLevel>
    <FixCategories>NonBreaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="DoNotDisposeRootWebAndParentWebProperties"
        Category="SharePoint.BestPractices"
        CheckId="SP0003">
    <Name>Do not dispose SPSite.RootWeb and SPWeb.ParentWeb properties</Name>
    <Description>The SPSite.RootWeb property and SPWeb.ParentWeb property no longer require Dispose() to be called on itself as previously indicated.</Description>
    <Resolution>In method '{0}', do not call the Dispose method for '{1}'.</Resolution>
    <MessageLevel Certainty="90">Warning</MessageLevel>
    <FixCategories>NonBreaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="DisposeSPSiteReturnedFromSPSiteCollectionAddMethod"
        Category="SharePoint.BestPractices"
        CheckId="SP0004">
    <Name>Dispose SPSite returned from the SPSiteCollection.Add method</Name>
    <Description>The SPSiteCollection.Add method creates and returns a new SPSite object. You should dispose of any SPSite object returned from the SPSiteCollection.Add method.</Description>
    <Resolution Name="Base">In method {0}, Dispose was not called on {1}.</Resolution>
    <Resolution Name="Constructor">In method {0}, constructor called for {1}. This type should be assigned and explicitely disposed.</Resolution>
    <Resolution Name="RootWebProp">In method {0}, Dispose was not called on {1} after a LockIssue, SecondaryContact, or Owner property call.</Resolution>
    <Resolution Name="PublishingWeb">In method {0}, Close was not called on {1}, which is enumerated from the PublishingWebCollection returned by GetPublishingWebs.</Resolution>
    <MessageLevel Certainty="100">Warning</MessageLevel>
    <FixCategories>NonBreaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="DisposeSPSiteReturnedFromSPSiteCollectionBracketsIndexOperator"
        Category="SharePoint.BestPractices"
        CheckId="SP0005">
    <Name>Dispose SPSite returned from the SPSiteCollection [] index operator</Name>
    <Description>The SPSiteCollection [] index operator returns a new SPSite object for each access. An SPSite instance is created even if that object has already been accessed. The recommended fix is to place a Dispose() at the end of each loop.</Description>
    <Resolution Name="Base">In method {0}, Dispose was not called on {1}.</Resolution>
    <Resolution Name="Constructor">In method {0}, constructor called for {1}. This type should be assigned and explicitely disposed.</Resolution>
    <Resolution Name="RootWebProp">In method {0}, Dispose was not called on {1} after a LockIssue, SecondaryContact, or Owner property call.</Resolution>
    <Resolution Name="PublishingWeb">In method {0}, Close was not called on {1}, which is enumerated from the PublishingWebCollection returned by GetPublishingWebs.</Resolution>
    <MessageLevel Certainty="100">Warning</MessageLevel>
    <FixCategories>NonBreaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="DisposeSPWebReturnedFromSPSiteAllWebsAddMethod"
        Category="SharePoint.BestPractices"
        CheckId="SP0006">
    <Name>Dispose SPWeb returned from the SPSite.AllWebs.Add method</Name>
    <Description>The SPSite.AllWebs.Add method(or SPWebCollection.Add) creates and returns an SPWeb object. You should dispose of any SPWeb object returned from SPSite.AllWebs.Add.</Description>
    <Resolution Name="Base">In method {0}, Dispose was not called on {1}.</Resolution>
    <Resolution Name="Constructor">In method {0}, constructor called for {1}. This type should be assigned and explicitely disposed.</Resolution>
    <Resolution Name="RootWebProp">In method {0}, Dispose was not called on {1} after a LockIssue, SecondaryContact, or Owner property call.</Resolution>
    <Resolution Name="PublishingWeb">In method {0}, Close was not called on {1}, which is enumerated from the PublishingWebCollection returned by GetPublishingWebs.</Resolution>
    <MessageLevel Certainty="100">Warning</MessageLevel>
    <FixCategories>NonBreaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="DisposeSPWebReturnedFromSPSiteAllWebsBracketsIndexOperator"
        Category="SharePoint.BestPractices"
        CheckId="SP0007">
    <Name>Dispose SPWeb returned from the SPSite.AllWebs [] index operator</Name>
    <Description>The SPSite.AllWebs [] index operator returns a new SPWeb instance each time it is accessed. An object is created during the indexing operation even if that object has already been accessed. If not properly closed, the following code samples leave an SPWeb object in the .NET Framework garbage collector.</Description>
    <Resolution Name="Base">In method {0}, Dispose was not called on {1}.</Resolution>
    <Resolution Name="Constructor">In method {0}, constructor called for {1}. This type should be assigned and explicitely disposed.</Resolution>
    <Resolution Name="RootWebProp">In method {0}, Dispose was not called on {1} after a LockIssue, SecondaryContact, or Owner property call.</Resolution>
    <Resolution Name="PublishingWeb">In method {0}, Close was not called on {1}, which is enumerated from the PublishingWebCollection returned by GetPublishingWebs.</Resolution>
    <MessageLevel Certainty="100">Warning</MessageLevel>
    <FixCategories>NonBreaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="DoNotDisposeSPSiteRootWebWhenUsingLockIssueOwnerOrSecondaryContact"
        Category="SharePoint.BestPractices"
        CheckId="SP0008">
    <Name>Do not dispose SPSite.RootWeb when using SPSite.LockIssue, SPSite.Owner or SPSite.SecondaryContact properties</Name>
    <Description>
      The following properties reference data from the top-level Web site and use the SPSite.RootWeb property:
      - SPSite.LockIssue
      - SPSite.Owner
      - SPSite.SecondaryContact
      For more information, see the discussion of SPSite.RootWeb. Based on the updated Microsoft guidance for RootWeb there is no longer a requirement to explicitly Dispose on any of these properties.
    </Description>
    <Resolution>In method {0}, Dispose was called on {1} after a LockIssue, SecondaryContact, or Owner property call, which is no longer a requirement.</Resolution>
    <MessageLevel Certainty="100">Warning</MessageLevel>
    <FixCategories>NonBreaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="DisposeSPWebReturnedFromSPWebWebsAddMethod"
        Category="SharePoint.BestPractices"
        CheckId="SP0009">
    <Name>Dispose SPWeb returned from the SPWeb.Webs.Add method</Name>
    <Description>The SPWeb.Webs.Add method creates and returns a new SPWeb object. You should dispose of any SPWeb object returned from this method call.</Description>
    <Resolution Name="Base">In method {0}, Dispose was not called on {1}.</Resolution>
    <Resolution Name="Constructor">In method {0}, constructor called for {1}. This type should be assigned and explicitely disposed.</Resolution>
    <Resolution Name="RootWebProp">In method {0}, Dispose was not called on {1} after a LockIssue, SecondaryContact, or Owner property call.</Resolution>
    <Resolution Name="PublishingWeb">In method {0}, Close was not called on {1}, which is enumerated from the PublishingWebCollection returned by GetPublishingWebs.</Resolution>
    <MessageLevel Certainty="100">Warning</MessageLevel>
    <FixCategories>NonBreaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="DisposeSPWebReturnedFromSPWebWebsBracketsIndexOperator"
        Category="SharePoint.BestPractices"
        CheckId="SP0010">
    <Name>Dispose SPWeb returned from the SPWeb.Webs [] index operator</Name>
    <Description>The SPWeb.Webs [] index operator returns a new SPWeb for each access. A new SPWeb is created by calling the OpenWeb method even if that object has already been accessed.</Description>
    <Resolution Name="Base">In method {0}, Dispose was not called on {1}.</Resolution>
    <Resolution Name="Constructor">In method {0}, constructor called for {1}. This type should be assigned and explicitely disposed.</Resolution>
    <Resolution Name="RootWebProp">In method {0}, Dispose was not called on {1} after a LockIssue, SecondaryContact, or Owner property call.</Resolution>
    <Resolution Name="PublishingWeb">In method {0}, Close was not called on {1}, which is enumerated from the PublishingWebCollection returned by GetPublishingWebs.</Resolution>
    <MessageLevel Certainty="100">Warning</MessageLevel>
    <FixCategories>NonBreaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="DisposeSPWebReturnedFromAreaWebProperty"
        Category="SharePoint.BestPractices"
        CheckId="SP0011">
    <Name>Dispose SPWeb returned from the Area.Web property</Name>
    <Description>The Area.Web property returns a new SPWeb object each time it is accessed. Any use of the Area.Web property should have a corresponding call to the Dispose method.</Description>
    <Resolution Name="Base">In method {0}, Dispose was not called on {1}.</Resolution>
    <Resolution Name="Constructor">In method {0}, constructor called for {1}. This type should be assigned and explicitely disposed.</Resolution>
    <Resolution Name="RootWebProp">In method {0}, Dispose was not called on {1} after a LockIssue, SecondaryContact, or Owner property call.</Resolution>
    <Resolution Name="PublishingWeb">In method {0}, Close was not called on {1}, which is enumerated from the PublishingWebCollection returned by GetPublishingWebs.</Resolution>
    <MessageLevel Certainty="100">Warning</MessageLevel>
    <FixCategories>NonBreaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="DisposeSPLimitedWebPartManagerWebProperty"
        Category="SharePoint.BestPractices"
        CheckId="SP0012">
    <Name>Dispose the SPLimitedWebPartManager.Web property</Name>
    <Description>When using the SPLimitedWebPartManager class a reference to an internal SPWeb object which needs to be disposed.</Description>
    <Resolution Name="Base">In method {0}, Dispose was not called on {1}.</Resolution>
    <Resolution Name="Constructor">In method {0}, constructor called for {1}. This type should be assigned and explicitely disposed.</Resolution>
    <Resolution Name="RootWebProp">In method {0}, Dispose was not called on {1} after a LockIssue, SecondaryContact, or Owner property call.</Resolution>
    <Resolution Name="PublishingWeb">In method {0}, Close was not called on {1}, which is enumerated from the PublishingWebCollection returned by GetPublishingWebs.</Resolution>
    <MessageLevel Certainty="100">Warning</MessageLevel>
    <FixCategories>NonBreaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="DoNotDisposeSPListParentWebWhenUsingSPListBreakRoleInheritanceMethod"
        Category="SharePoint.BestPractices"
        CheckId="SP0013">
    <Name>Do not dispose SPList.ParentWeb when using the SPList.BreakRoleInheritance method</Name>
    <Description>When using the SPList.BreakRoleInheritance() method, an internal call to ParentWeb property is called. SPList.BreakRoleInheritance() method no longer requires list.ParentWeb.Dispose() to be executed after calling BreakRoleInheritance() due to the updated ParentWeb guidance.</Description>
    <Resolution>In method {0}, Dispose was called on {1}.ParentWeb after using the {1}.BreakRoleInheritance method, which is no longer a requirement.</Resolution>
    <MessageLevel Certainty="100">Warning</MessageLevel>
    <FixCategories>NonBreaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="ClosePublishingWebReturnedFromPublishingWebGetPublishingWebsBracketsIndexOperator"
        Category="SharePoint.BestPractices"
        CheckId="SP0014">
    <Name>Close PublishingWeb returned from the PublishingWeb.GetPublishingWebs [] index operator</Name>
    <Description>When using the PublishingWeb class, GetPublishingWebs method which returns a PublishingWebCollection you are required to call Close on the enumerated innerPubWeb objects.  Note that when you are only calling GetPublishingWeb method without using the GetPublishingWebs collection you are not required to explicitly call close.</Description>
    <Resolution Name="Base">In method {0}, Dispose was not called on {1}.</Resolution>
    <Resolution Name="Constructor">In method {0}, constructor called for {1}. This type should be assigned and explicitely disposed.</Resolution>
    <Resolution Name="RootWebProp">In method {0}, Dispose was not called on {1} after a LockIssue, SecondaryContact, or Owner property call.</Resolution>
    <Resolution Name="PublishingWeb">In method {0}, Close was not called on {1}, which is enumerated from the PublishingWebCollection returned by GetPublishingWebs.</Resolution>
    <MessageLevel Certainty="90">Warning</MessageLevel>
    <FixCategories>NonBreaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="DoNotDisposeSPSiteAndSPWebReturnedFromGetContextSiteAndGetContextWebMethods"
        Category="SharePoint.BestPractices"
        CheckId="SP0015">
    <Name>Do not dispose SPSite and SPWeb returned from the GetContextSite and GetContextWeb methods</Name>
    <Description>GetContextSite(Context) and GetContextWeb(Context) methods return SPSite and SPWeb objects respectively that DO NOT need a call to Dispose() and will be disposed automatically by SharePoint.</Description>
    <Resolution>In method '{0}', do not call the Dispose method for '{1}'.</Resolution>
    <MessageLevel Certainty="100">CriticalError</MessageLevel>
    <FixCategories>Breaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="DoNotDisposeSPSiteAndSPWebReturnedFromSPContextProperties"
        Category="SharePoint.BestPractices"
        CheckId="SP0016">
    <Name>Do not dispose SPSite and SPWeb returned from the SPContext.Current.Site, SPContext.Site, SPContext.Current.Web and SPContext.Web properties</Name>
    <Description>SPContext.Current.Site and SPContext.Site as well as SPContext.Current.Web and SPContext.Web properties return SPSite and SPWeb objects respectively that DO NOT need a call to Dispose and will be disposed automatically by SharePoint.</Description>
    <Resolution>In method '{0}', do not call the Dispose method for '{1}'.</Resolution>
    <MessageLevel Certainty="100">CriticalError</MessageLevel>
    <FixCategories>Breaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>


  <Rule TypeName="DoNotDisposeSPSiteAndSPWebReturnedFromSPFeatureParent"
        Category="SharePoint.BestPractices"
        CheckId="SP0017">
    <Name>Do not dispose SPSite and SPWeb returned from the SPFeature.Parent property</Name>
    <Description>SPFeature.Parent property return SPSite or SPWeb objects that are get from SPContext and that DO NOT need a call to Dispose and will be disposed automatically by SharePoint.</Description>
    <Resolution>In method '{0}', do not call the Dispose method for '{1}'.</Resolution>
    <MessageLevel Certainty="100">CriticalError</MessageLevel>
    <FixCategories>Breaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="ClosePublishingWebReturnedFromPublishingWebGetVariation"
        Category="SharePoint.BestPractices"
        CheckId="SP0018">
    <Name>Close PublishingWeb returned from the PublishingWeb.GetVariation method</Name>
    <Description>PublishingWeb.GetVariation() method returns a PublishingWeb object which which needs to be explicitly closed.</Description>
    <Resolution Name="Base">In method '{0}', Close was not called on '{1}', although it was returned from the PublishingWeb.GetVariation method.</Resolution>
    <MessageLevel Certainty="90">Warning</MessageLevel>
    <FixCategories>Breaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>

  <Rule TypeName="DisposeSPSiteReturnedFromUserProfilesPersonalSite"
        Category="SharePoint.BestPractices"
        CheckId="SP0019">
    <Name>Dispose SPSite returned from the UserProfiles.PersonalSite property</Name>
    <Description>UserProfiles.PersonalSite requires a Dispose() call before leaving scope if you use the property in your code.</Description>
    <Resolution Name="Base">In method '{0}', Dispose was not called on '{1}', although it was returned from the UserProfiles.PersonalSite property.</Resolution>
    <MessageLevel Certainty="90">Warning</MessageLevel>
    <FixCategories>Breaking</FixCategories>
    <Url>http://sovfxcoprules.codeplex.com</Url>
    <Email>adrien.siffermann@gmail.com</Email>
    <Owner>Adrien Siffermann</Owner>
  </Rule>
</Rules>